import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.Random;

import rmiClient.Client_IMPL;
import rmiClient.score;

/**
 * 
 */

/**
 * @author arthur
 * 
 */
public class testelection {

	/**
	 * @param args
	 * @throws RemoteException
	 */
	public static void main(String[] args) throws RemoteException {
		ArrayList<Client_IMPL> clients = new ArrayList<Client_IMPL>();
		Random r = new Random();

		for (int i = 0; i < 50; i++) {
			int scoreNewClient = r.nextInt(10000);
			clients.add(new Client_IMPL(null, i, scoreNewClient));
			if (i > 0) {
				int newNeighbor = r.nextInt(i);
				clients.get(i).getNeighbors().add(clients.get(newNeighbor));
				clients.get(newNeighbor).getNeighbors().add(clients.get(i));
				System.out
						.println("New Client id:" + i + " score:"
								+ scoreNewClient + " is neigbohrs with :"
								+ newNeighbor);
			}
		}

		for (int i = 0; i < clients.size(); i++) {
			score res = clients.get(i).election(null);

			System.out.println("Id ClientElected :"
					+ ((Client_IMPL) res.getClient()).getId()
					+ " with a score of " + res.getScore());
		}

		score res = clients.get(0).election("Kikoo");
		score res2 = clients.get(30).election("Kikoo");

		System.out.println("Id ClientElected :"
				+ ((Client_IMPL) res.getClient()).getId() + " with a score of "
				+ res.getScore());

		if (res2.getClient() == null) {
			System.out
					.println("La secondes éléction <<Kikoo>> renvois un client null et un score :"
							+ res2.getScore());
		}

	}
}
